#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <aclconio.h>
#include <define.h>
#include <transact.h>
#include <tran.h>
#include <gds.h>
#include <sizes.h>
#include "ConfProto.h"
#include "tblutil.h"
#include <\SOFTPAY\Ver30\source\include\sizes.h>
#include <\SOFTPAY\Ver30\HostSrc\citisrc\citiids.h>
#include <\SOFTPAY\Ver30\HostSrc\cpacsrc\cpacids.h>
#include <confio.h>

#include <\SOFTPAY\Ver30\source\include\MCT.h>



static void *storeFromStruct;

static int recordNum;
void registerMCT(void *ptr)
{
	 storeFromStruct = ptr;
}

void *dealWithAddressBoundary(void*address);
int	inLoadMCTRecFromStruct (int inRecNumber, void *vdStruct)
{
	int inRet;
	char* tmp = (char*)vdStruct;

	registerMCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inLoadConfRec(MCT_FILENAME, SIZE_MCT_REC, inRecNumber, vdStruct);

	recordNum = inRecNumber;
	return inRet;
}

void vdRestoreMCTRecFromStruct(void *vdStruct)
{
	registerMCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	memcpy((char *) pvdGetMCTRec(), vdStruct, SIZE_MCT_REC);

}

void vdCopyMCTRecFromStruct(void *vdStruct)
{
	registerMCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
		memcpy(vdStruct, (char *) pvdGetMCTRec(), SIZE_MCT_REC);

}

int	inSaveMCTRecFromStruct (int inRecNumber,  void *vdStruct)
{
	int inRet;

	registerMCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(MCT_FILENAME, SIZE_MCT_REC, inRecNumber, (char *) vdStruct);

	return inRet;
}

int	inUpdateMCTRecFromStruct (void *vdStruct)
{
	int inRet;

	registerMCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(MCT_FILENAME, SIZE_MCT_REC, recordNum, (char *) vdStruct);

	return inRet;
}

long lnGetDestMANFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetDestMAN();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->lnDestMAN;
}

void vdSetDestMANFromStruct(long lnDestMAN, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetDestMAN(lnDestMAN);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->lnDestMAN = lnDestMAN;
}

long lnGetSecondaryMANFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetSecondaryMAN();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->lnSecondaryMAN;
}

void vdSetSecondaryMANFromStruct(long lnSecondaryMAN, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSecondaryMAN(lnSecondaryMAN);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->lnSecondaryMAN = lnSecondaryMAN;
}

long lnGetDestSettleMANFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetDestSettleMAN();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->lnDestSettleMAN;
}

void vdSetDestSettleMANFromStruct(long lnDestSettleMAN, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetDestSettleMAN(lnDestSettleMAN);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->lnDestSettleMAN = lnDestSettleMAN;
}

long lnGetSecSettleMANFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetSecSettleMAN();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->lnSecSettleMAN;
}

void vdSetSecSettleMANFromStruct(long lnSecSettleMAN, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSecSettleMAN(lnSecSettleMAN);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->lnSecSettleMAN = lnSecSettleMAN;
}

short shGetMBTXBaudRateFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return shGetMBTXBaudRate();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->shMBTXBaudRate;
}

void vdSetMBTXBaudRateFromStruct(short shMBTXBaudRate, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMBTXBaudRate(shMBTXBaudRate);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->shMBTXBaudRate = shMBTXBaudRate;
}

short shGetMBTXDataFormatFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return shGetMBTXDataFormat();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->shMBTXDataFormat;
}

void vdSetMBTXDataFormatFromStruct(short shMBTXDataFormat, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMBTXDataFormat(shMBTXDataFormat);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->shMBTXDataFormat = shMBTXDataFormat;
}

short shGetMBTXTimeoutFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return shGetMBTXTimeout();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->shMBTXTimeout;
}

void vdSetMBTXTimeoutFromStruct(short shMBTXTimeout, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMBTXTimeout(shMBTXTimeout);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->shMBTXTimeout = shMBTXTimeout;
}

short inGetRSSIThresholdFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetRSSIThreshold();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->inRSSIThreshold;
}

void vdSetRSSIThresholdFromStruct(short inRSSIThreshold, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRSSIThreshold(inRSSIThreshold);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->inRSSIThreshold = inRSSIThreshold;
}

short shGetMBTXParityFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return shGetMBTXParity();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->shMBTXParity;
}

void vdSetMBTXParityFromStruct(short shMBTXParity, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMBTXParity(shMBTXParity);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->shMBTXParity = shMBTXParity;
}

VS_BOOL fGetDialBackupFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetDialBackup();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->fDialBackup;
}

void vdSetDialBackupFromStruct(VS_BOOL fDialBackup, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetDialBackup(fDialBackup);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->fDialBackup = fDialBackup;
}

VS_BOOL fGetWirelessHostFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetWirelessHost();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MCT_REC*)vdStruct)->fWirelessHost;
}

void vdSetWirelessHostFromStruct(VS_BOOL fWirelessHost, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetWirelessHost(fWirelessHost);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MCT_REC*)vdStruct)->fWirelessHost = fWirelessHost;
}

